//
// Created by DELL on 2025/2/13.
//

#ifndef SEMAPHORE_H
#define SEMAPHORE_H
#include <condition_variable>
#include <mutex>

namespace zdotp {

class Semaphore {
public:
    explicit Semaphore(const int limit = 0) : ref_limit_(limit){}
    ~Semaphore() = default;
    void wait();
    void post();
private:
    int ref_limit_;
    std::mutex mtx_;
    std::condition_variable cv_;
};

} // zdotp

#endif //SEMAPHORE_H
